<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='sys_dept'">
<meta charset="utf-8">
<header th:replace="header::header(${title})"></header>
<body class="gray-bg">
	<div class="wrapper wrapper-content ">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="DeptForm">
							<input id="dept_id" name="deptId" th:value="${dept.deptId}" type="hidden">
							<div class="form-group">
								<label class="col-sm-3 control-label">上级部门名称：</label>
								<div class="col-sm-8">
									<input id="pDeptName" name="pDeptName" readonly="readonly" class="form-control" type="text" th:value="${pDeptName}">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">部门名称：</label>
								<div class="col-sm-8">
									<input id="deptName" name="deptName" th:value="${dept.deptName}" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">排序：</label>
								<div class="col-sm-8">
									<input id="orderNo" name="orderNo" th:value="${dept.orderNo}" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">状态：</label>
								<div class="col-sm-8">
									<label class="radio-inline"> <input th:field="*{dept.status}" type="radio" name="status" value="1" /> 正常
									</label> <label class="radio-inline"> <input th:field="*{dept.status}" type="radio" name="status" value="0" /> 禁用
									</label>
								</div>
							</div>
							<div class="form-group">
								<div class="col-sm-8 col-sm-offset-3">
									<button type="submit" class="btn btn-primary" >提交</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:replace="footer :: footer"></div>
	<script type="text/javascript" >
	var prefix = ctx + "sys/dept"
	$().ready(function() {
        validateRule();
    });

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#DeptForm").validate({
            rules : {
	            deptName : {
		            required : true
	            },
            },
            messages : {
	            deptName : {
		            required : icon + "请输入部门名称"
	            },
            }
        })
    }

    $.validator.setDefaults({
        submitHandler : function() {
        	update();
        }
    });

    function update() {
       YiMo.ajaxPut({
            url : prefix + "/update",
            data : $('#DeptForm').serialize(),
            needClose : true,
            parentRefresh : true,
        });
    }
	</script>
</body>
</html>
